/* iOcumedFactory.java
 *
 * @author Team D, B
 * @date 15.05.2008
 *
 * iOcumed interface
 */

package ocumed.teams;

import java.lang.reflect.Method;

/**
 * create the ocumed handler (catalog) for both teams
 * singleton/factory pattern.
 * 
 * @author Daniel Rudigier
 * @author Willi
 */
public abstract class OcumedFactory {
    private static IOcumed instance;
    
    /**
     * return a implementation for the catalog
     * using a singleton
     * 
     * @return the ocumed handler
     */
    @SuppressWarnings("unchecked")
    public static IOcumed getInstance() {
        if (instance == null) {
            try {
                Class cls = Class.forName("ocumed.domain.Ocumed");
                Method m = cls.getMethod("getInstance", new Class[0]);
                instance = (IOcumed) m.invoke(cls);
            } catch (Exception e1) {
                try {
                    instance = (IOcumed) Class.forName("ocumed.applikation.domainhandling.OcumedHandler").newInstance();
                } catch (Exception e2) {
                    System.out.println("domain handler could not be instantiated.");
                } 
            }       
        }
        return instance;
    }
}
